<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class Refund extends Model
{
    use HasDateTimeFormatter;

    const STATE_WAIT_CHECK = 1;//待审核
    const STATE_PASSED = 2;//已通过
    const STATE_REJECTED = 3;//已驳回
    const STATE_REFUND_SUCCESS = 4;//退款成功
    const STATE_REFUND_FAIL = 5;//退款失败

    protected $table = 'refund';

    public static function getSn()
    {
        $sn = date('YmdHis') . rand(1000, 9999);
        return $sn;
    }

    public static function checkMap()
    {
        return [
            self::STATE_PASSED => '通过',
            self::STATE_REJECTED => '驳回'
        ];
    }

    public static function stateMap()
    {
        return [
            self::STATE_WAIT_CHECK => '待审核',
            self::STATE_PASSED => '已通过',
            self::STATE_REJECTED => '已驳回',
            self::STATE_REFUND_SUCCESS => '退款成功',
            self::STATE_REFUND_FAIL => '退款失败'
        ];
    }
}
